package com.smart_environmental_protection.dao;

import com.smart_environmental_protection.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


@Repository
public interface UserDao {
    @Select("select * from s_user where phoneNum=#{phoneNum} and password=#{password}")
    User login(User user);
    @Select("select * from s_user where phoneNum=#{phoneNum}")
    User Userlogin(User user);

    @Select({"select * from s_user where id=#{id}"})
    User getUserById(Integer id);

    @Update({"update s_user set icon=#{icon}  where id=#{id}"})
    int updateIcon(User user);

    @Insert({"INSERT INTO `smartep`.`s_user`(`phoneNum`, `password`, `nickName`) VALUES (#{phoneNum},#{password}, #{nickName})"})
int InsertUser(User user);

    @Update({"UPDATE `smartep`.`s_user` SET `password` = #{password} WHERE `phoneNum` = #{phoneNum}"})
    int UpdateUser(User user);
    @Update({"UPDATE `smartep`.`s_user` SET `phoneNum` = #{phoneNum} WHERE `id` = #{id}"})
    int UpdatePhone(User user);

    @Update({"UPDATE `smartep`.`s_user` SET `password` = #{password} WHERE `id` = #{id}"})
    int UpdatePws(User user);


}
